/*
 * $Id: $
 * 
 * Copyright (c) 2001-2008 Accentrix Company Limited. All Rights Reserved.
 * 
 * Accentrix Company Limited. ("Accentrix") retains copyright on all text, source
 * and binary code contained in this software and documentation. Accentrix grants
 * Licensee a limited license to use this software, provided that this copyright
 * notice and license appear on all copies of the software. The software source
 * code is provided for reference purposes only and may not be copied, modified 
 * or distributed.
 * 
 * THIS SOFTWARE AND DOCUMENTATION ARE PROVIDED "AS IS," WITHOUT ANY WARRANTY OF
 * ANY KIND UNLESS A SEPARATE WARRANTIES IS PURCHASED FROM ACCENTRIX AND REMAINS
 * VALID.  ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
 * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 * PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. ACCENTRIX SHALL NOT BE LIABLE
 * FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING OR MODIFYING THE
 * SOFTWARE OR ITS DERIVATIVES.
 * 
 * IN NO EVENT WILL ACCENTRIX BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR
 * FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES,
 * HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE
 * USE OF OR INABILITY TO USE SOFTWARE, EVEN IF ACCENTRIX HAS BEEN ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGES.
 */
package com.snowleopard.common.constants;

import org.apache.commons.lang.xwork.StringUtils;
import org.apache.log4j.Logger;

/**
 * Define constants of this application<br>
 * All constants will come from the property file 'appConstants.properties'.
 * 
 * @author LiuJian
 * 
 */
public class AppConstant {

	private static final Logger log = Logger.getLogger(AppConstant.class);

	public static final String APP_NAME;
	public static final String LOGIN_USER = "loginUser";

	static {

		try {
			if (log.isInfoEnabled()) {
				log.info("==========================================");
				log.info("        AppConstant Initialization        ");
				log.info("==========================================");
			}

			APP_NAME = AppConstantProperties.getPropValue("app.name");
			if (StringUtils.isBlank(APP_NAME)) {
				new RuntimeException("Can't find key or value of 'app.name' mapping to 'APP_CODE'");
			}

			if (log.isInfoEnabled()) {
				log.info("APP_CODE: " + APP_NAME);

				log.info("==========================================");
				log.info("    AppConstant Initialize successfull    ");
				log.info("==========================================");
			}

		} catch (Exception e) {

			log.error("==========================================");
			log.error("     AppConstant Initialization Fail      ");
			log.error("==========================================");

			throw new RuntimeException(e.getMessage() + " in property file 'appConstants.properties.", e);
		}
	}
}
